﻿using System;
using System.Activities;
using System.Collections.Generic;
using KPIS.GERP.SERVICE.Model;

namespace KPIS.GERP.SERVICE.WorkflowService.CodeActivity
{
    public sealed class Select_Message : CodeActivity<List<message>>
    {
        public InArgument<string> in_message_seq { get; set; }
        public InArgument<string> in_from_emp_seq { get; set; }
        public InArgument<string> in_to_emp_seq { get; set; }
        public InArgument<string> in_from_message_seq { get; set; }
        public InArgument<string> in_task_approve_seq { get; set; }
        public InArgument<string> in_rule_approve_seq { get; set; }

        /// <summary>
        /// set True for join this object
        /// </summary>
        public InArgument<bool> in_IsGetReference { get; set; }
        /// <summary>
        /// set True for join this object
        /// </summary>
        public InArgument<bool> in_IsGetFromEmployee { get; set; }
        /// <summary>
        /// set True for join this object
        /// </summary>
        public InArgument<bool> in_IsGetToEmployee { get; set; }
        /// <summary>
        /// set True for join this object
        /// </summary>
        public InArgument<bool> in_IsGetFromMessage { get; set; }
        /// <summary>
        /// set True for join this object
        /// </summary>
        public InArgument<bool> in_IsGetRuleApprove { get; set; }
        /// <summary>
        /// set True for join this object
        /// </summary>
        public InArgument<bool> in_IsGetTaskApprove { get; set; }

        protected override List<message> Execute(CodeActivityContext context)
        {
            List<message> list = new DAL.Message().GetMessage(
                in_message_seq.Get(context)
                , in_from_emp_seq.Get(context)
                , in_to_emp_seq.Get(context)
                , in_from_message_seq.Get(context)
                , in_task_approve_seq.Get(context)
                , in_rule_approve_seq.Get(context)

                , in_IsGetReference.Get(context)
                , in_IsGetFromEmployee.Get(context)
                , in_IsGetToEmployee.Get(context)
                , in_IsGetFromMessage.Get(context)
                , in_IsGetRuleApprove.Get(context)
                , in_IsGetTaskApprove.Get(context));
            return list;
        }
    }

    public sealed class Insert_Message : CodeActivity<string>
    {
        public InArgument<string> in_message_no { get; set; }
        public InArgument<DateTime> in_message_date { get; set; }
        public InArgument<string> in_message_title { get; set; }
        public InArgument<string> in_message_descr { get; set; }
        public InArgument<string> in_from_emp_seq { get; set; }
        public InArgument<string> in_to_emp_seq { get; set; }
        public InArgument<string> in_from_message_seq { get; set; }
        public InArgument<string> in_task_approve_seq { get; set; }
        public InArgument<string> in_rule_approve_seq { get; set; }
        public InArgument<int> in_approval_action_count { get; set; }
        public InArgument<string> in_message_status { get; set; }
        public InArgument<string> in_remarks { get; set; }
        public InArgument<string> in_record_status { get; set; }
        public InArgument<string> in_created_by { get; set; }

        protected override string Execute(CodeActivityContext context)
        {
            return new DAL.Message().InsertMessage(
                in_message_no.Get(context)
                , in_message_date.Get(context)
                , in_message_title.Get(context)
                , in_message_descr.Get(context)
                , in_from_emp_seq.Get(context)
                , in_to_emp_seq.Get(context)
                , in_from_message_seq.Get(context)
                , in_task_approve_seq.Get(context)
                , in_rule_approve_seq.Get(context)
                , in_message_status.Get(context)
                , in_remarks.Get(context)
                , in_record_status.Get(context)
                , in_created_by.Get(context)
                , in_approval_action_count.Get(context));
        }
    }

    public sealed class Update_Message : System.Activities.CodeActivity
    {
        [RequiredArgument]
        public InArgument<string> in_message_seq { get; set; }
        public InArgument<string> in_message_no { get; set; }
        public InArgument<DateTime> in_message_date { get; set; }
        public InArgument<string> in_message_title { get; set; }
        public InArgument<string> in_message_descr { get; set; }
        public InArgument<string> in_from_emp_seq { get; set; }
        public InArgument<string> in_to_emp_seq { get; set; }
        public InArgument<string> in_from_message_seq { get; set; }
        public InArgument<string> in_task_approve_seq { get; set; }
        public InArgument<string> in_rule_approve_seq { get; set; }
        public InArgument<int> in_action_count { get; set; }
        public InArgument<string> in_message_status { get; set; }
        public InArgument<string> in_remarks { get; set; }
        public InArgument<string> in_record_status { get; set; }
        public InArgument<string> in_updated_by { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            new DAL.Message().UpdateMessage(
                in_message_seq.Get(context)
                , in_message_no.Get(context)
                , in_message_date.Get(context)
                , in_message_title.Get(context)
                , in_message_descr.Get(context)
                , in_from_emp_seq.Get(context)
                , in_to_emp_seq.Get(context)
                , in_from_message_seq.Get(context)
                , in_task_approve_seq.Get(context)
                , in_rule_approve_seq.Get(context)
                , in_message_status.Get(context)
                , in_remarks.Get(context)
                , in_record_status.Get(context)
                , in_updated_by.Get(context)
                , in_action_count.Get(context));
        }
    }

    public sealed class UpdateStatus_Message : System.Activities.CodeActivity
    {
        [RequiredArgument]
        public InArgument<string> in_message_seq { get; set; }

        [RequiredArgument]
        public InArgument<string> in_record_status { get; set; }
        public InArgument<string> in_updated_by { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            new DAL.Message().UpdateStatusMessage(
                in_message_seq.Get(context)
                , in_record_status.Get(context)
                , in_updated_by.Get(context));
        }
    }
}
